import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;


public class confirm_multi{
	public static void main(String[] args) throws Exception {
            ConnectionFactory cf = new ConnectionFactory();
            cf.setHost("192.168.1.110");
            cf.setUsername("liwenbin");
            cf.setPassword("123456");
            Connection connection = cf.newConnection();
            Channel channel = connection.createChannel();
            String message = "Hello World!";
            String QUEUE_NAME = "hello";
            channel.confirmSelect();
            for(int i=0;i<10;i++){
                channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
            }

            if(!channel.waitForConfirms()){
                 System.out.println("send message failed.");
            }else{
                 System.out.println("send ok");
            }
            channel.close();
            connection.close();
	}
}

